﻿<UserControl x:Class="Epi.WPF.Dashboard.Controls.DataDictionaryControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:CommonControls="clr-namespace:Epi.WPF.Controls;assembly=Epi.WPF"
             mc:Ignorable="d" 
             d:DesignHeight="200" d:DesignWidth="200">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../ResourceDictionary.xaml"/>
                <ResourceDictionary>
                    <SolidColorBrush x:Key="BackgroundBrush" Color="White" />
                    <SolidColorBrush x:Key="HighlightBackgroundBrush" Color="#E1E1E1" />
                    <!--<SolidColorBrush x:Key="HighlightCellBackgroundBrush" Color="#E1E1E1" />-->

                    <Style x:Key="GridViewColumnHeaderGripper" TargetType="Thumb">
                        <Setter Property="Width" Value="18"/>
                        <Setter Property="Background" Value="{DynamicResource windowBorderColor}"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type Thumb}">
                                    <Border Padding="{TemplateBinding Padding}" Background="Transparent">
                                        <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>

                    <Style x:Key="{x:Type GridViewColumnHeader}" TargetType="GridViewColumnHeader">
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey }}" />
                        <Setter Property="FontSize" Value="11pt" />
                        <Setter Property="Padding" Value="4"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="GridViewColumnHeader">
                                    <Grid>
                                        <Border Name="HeaderBorder" Padding="{TemplateBinding Padding}" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource windowBorderColor}" Background="{StaticResource BackgroundBrush}">
                                            <ContentPresenter Name="HeaderContent" Margin="0,0,0,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        </Border>
                                        <Thumb x:Name="PART_HeaderGripper" HorizontalAlignment="Right" Margin="0,0,-9,0" Style="{StaticResource GridViewColumnHeaderGripper}"/>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="true">
                                            <Setter TargetName="HeaderBorder" Property="Background" Value="{StaticResource HighlightBackgroundBrush}"/>
                                        </Trigger>
                                        <Trigger Property="IsPressed" Value="true">
                                            <Setter TargetName="HeaderBorder" Property="Background" Value="{StaticResource windowDarkColor}"/>
                                            <Setter TargetName="HeaderContent" Property="Margin" Value="1,1,0,0"/>
                                        </Trigger>
                                        <Trigger Property="IsEnabled" Value="false">
                                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property="Role" Value="Floating">
                                <Setter Property="Opacity" Value="0.7"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="GridViewColumnHeader">
                                            <Canvas Name="PART_FloatingHeaderCanvas">
                                                <Rectangle Fill="#60000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}"/>
                                            </Canvas>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <Trigger Property="Role" Value="Padding">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="GridViewColumnHeader">
                                            <Border Name="HeaderBorder" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource windowBorderColor}" Background="{StaticResource BackgroundBrush}"/>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </Style.Triggers>
                    </Style>

                    <Style x:Key="ListViewItemContainerStyle" TargetType="{x:Type ListViewItem}">
                        <Setter Property="Background" Value="#ffffff" />
                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        <Setter Property="VerticalContentAlignment" Value="Center" />
                        <Setter Property="Foreground" Value="Black" />
                        <Setter Property="Margin" Value="0,0,0,0" />
                        <Setter Property="FontSize" Value="10pt" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListViewItem}">
                                    <Border x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true" Padding="0,0,0,0" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource windowBorderColor}">
                                        <!--<GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />-->
                                        <CommonControls:GridViewRowPresenterWithGridLines VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                            Columns="{TemplateBinding GridView.ColumnCollection}"
                                            Margin="1,0,0,0"
                                            />
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsSelected"  Value="true">
                                            <Setter TargetName="Bd" Property="BorderBrush" Value="#FF143c65" />
                                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource windowDarkColor}" />
                                            <Setter Property="BorderBrush" TargetName="Bd" Value="#FF143c65"/>
                                            <Setter Property="Foreground" Value="White"/>
                                        </Trigger>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="Bd" Property="Background" Value="{StaticResource HighlightBackgroundBrush}" />
                                        </Trigger>
                                        <MultiTrigger>
                                            <MultiTrigger.Conditions>
                                                <Condition Property="IsSelected" Value="true" />
                                                <Condition Property="Selector.IsSelectionActive" Value="True" />
                                            </MultiTrigger.Conditions>
                                            <Setter Property="Background" TargetName="Bd" Value="{DynamicResource windowDarkColor}" />
                                            <Setter Property="BorderBrush" TargetName="Bd" Value="#FF143c65"/>
                                            <Setter Property="Foreground" Value="White"/>
                                        </MultiTrigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>


                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <ListView x:Name="lvMain" GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler" ItemContainerStyle="{DynamicResource ListViewItemContainerStyle}">
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem x:Name="mnuNew" Header="New field" />
                    <MenuItem x:Name="mnuEdit" Header="Edit field" />
                    <MenuItem x:Name="mnuDelete" Header="Delete field" />
                    <Separator />
                    <MenuItem x:Name="mnuCreateGroup" Header="Create a field group" />
                    <Separator />
                    <MenuItem x:Name="mnuFrequency" Header="Frequency..." />
                    <MenuItem x:Name="mnuMeans" Header="Mean/Median/Mode/Min/Max..." />
                    <MenuItem x:Name="mnuChart" Header="Charts">
                        <MenuItem x:Name="mnuPieChart" Header="Pie chart" />
                        <MenuItem x:Name="mnuColumnChart" Header="Column chart" />
                        <MenuItem x:Name="mnuBarChart" Header="Bar chart" />
                        <MenuItem x:Name="mnuEpiCurve" Header="Epi Curve" />
                    </MenuItem>                    
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>
    </Grid>
</UserControl>
